home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5430 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: int main() vs int main(void)
  5. Date: Fri, 09 Feb 96 23:59:01 GMT
  6. Organization: none
  7. Message-ID: <823910341snz@genesis.demon.co.uk>
  8. References: <1996Feb7.201848.18734@atlas.tntech.edu> <danpop.823791491@rscernix>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <danpop.823791491@rscernix> danpop@mail.cern.ch "Dan Pop" writes:
  15.  
  16. >In <1996Feb7.201848.18734@atlas.tntech.edu> jad7084@tntech.edu (Jim Davis)
  17. > writes:
  18. >
  19. >>Okay, void main() is naughty, but there's something else I've been
  20. >>wondering about, and I can't find it in the FAQ.
  21. >>
  22. >>Is there a difference between
  23. >>
  24. >>  int main()
  25. >>  int main(void)
  26. >>
  27. >>?  () is equivalent to (void), right?  Does it matter?  Am I worried about
  28. >>nothing?
  29. >
  30. >As part of a function definition, the two forms are 100% equivalent.
  31. >
  32. >As function declarations, the second is a prototype while the first
  33. >allows main to be called with any (number and type of) arguments.
  34.  
  35. The first doesn't tell you the correct number and types of the
  36. arguments you must supply, or let the compiler check them. However the
  37. arguments you supply must still match those in the function definition if
  38. you want to avoid undefined behaviour.
  39.  
  40. It is however correct to say that the first form as a declaration is
  41. compatible with any (fixed argument) declaration/definition of main that
  42. returns int.
  43.  
  44. -- 
  45. -----------------------------------------
  46. Lawrence Kirby | fred@genesis.demon.co.uk
  47. Wilts, England | 70734.126@compuserve.com
  48. -----------------------------------------
  49.